package com.itheima.huikebackend.mapper;

import com.github.pagehelper.Page;
import com.itheima.huikebackend.dto.SysUserDTO;
import com.itheima.huikebackend.dto.SysUserPageDTO;
import com.itheima.huikebackend.dto.SysUserUpdateDTO;
import com.itheima.huikebackend.entity.SysMenu;
import com.itheima.huikebackend.entity.SysUser;
import com.itheima.huikebackend.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author iTaotao
 * @version 1.0
 * @date 2023/08/07 17:26:36
 */
@Mapper
public interface SysUserMapper {

    /**
     * 查找系统用户
     *
     * @param username 用户名
     * @return {@link SysUser}
     */
    @Select("select * from sys_user where user_name = #{username} ")
    SysUser selectSysUserByUserName(String username);

    void insertCode(String code, String uuid);

    @Select("select count(*) from code where code = #{code}")
    Integer selectCode(String code);


    @Select("select * from sys_menu")
    List<SysMenu> selectSysMenus();

    SysUser selectUserInfoById(String currentId);

    /**
     * Description 分页查询user
     * @param userPageDTO
     * @return com.github.pagehelper.Page<com.itheima.huikebackend.vo.UserViewVO>
     * Date 2023/8/8
     */
    Page<SysUserViewVO> selectByPage(SysUserPageDTO userPageDTO);

    List<SysPostVO> selectSysPost();

    List<SysRoleVO> selectSysRole();

    SysUserEchoVO selectUserById(String id);

    void insertUser(SysUser sysUser);

    void deleteUser(Long id);

    void updateUserPassword(SysUserUpdateDTO sysUserUpdateDTO);

    @Select("select * from sys_user;")
    List<SysUserViewVO> selectAllUser();
}
